/*
    Copyright (C) 2011 Rémi Thebault

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program. If not, see <http://www.gnu.org/licenses/>.
*/


#ifndef TASKSELECTIONMODEL_H
#define TASKSELECTIONMODEL_H

#include <QObject>
#include <QList>

#include <procycle/cycle.h>


class TaskSelectionModel : public QObject
{
	Q_OBJECT
public:

	TaskSelectionModel (PC::Cycle* cycle, QObject* parent=0);

	void resetCycle(PC::Cycle* cycle);

	PC::Task* selectedTask() const {
		return m_selectedTask;
	}

	PC::Link* selectedLink() const {
		return m_selectedLink;
	}

	bool hasSelection() const {
		return m_selectedTask || m_selectedLink;
	}

public slots:
	void selectTask(PC::Task* task, bool selected=true);
	void selectLink(PC::Link* link,  bool selected=true);

	void clearSelection();

	void taskWillDelete(PC::Task* task);
	void linkWillDelete(PC::Link* task);

signals:
	void taskSelectionChanged(PC::Task* selected, PC::Task* unselected);
	void linkSelectionChanged(PC::Link* selected, PC::Link* unselected);

private:
	PC::Cycle*			m_cycle;

	PC::Task*			m_selectedTask;
	PC::Link*			m_selectedLink;
};



#endif // TASKSELECTIONMODEL_H
